<?php
require_once("func.php");

#debug($_POST);

if(!empty($_POST['submit']))
{
	if($_POST['submit'] === "submit")
	{
		$sql = "	update todos set 
						pid='".$_POST['pid']."', 
						txt='".$_POST['txt']."',
						prio='".$_POST['prio']."',
						severity='".$_POST['severity']."',
						hours='".$_POST['hours']."'
					where id = '".$_GET['id']."'";
		dbq($sql);
		header("Location: index.php?zoom_id=".$_GET['zoom_id']."");
		exit();
	}
}

#echo "_GET[id] = ".$_GET['id']."<p>";

require_once("top.php");

$sql = "select txt from todos where id = '".$_GET['id']."'";
$txt = dbq1($sql);

$sql = "select prio from todos where id = '".$_GET['id']."'";
$prio = dbq1($sql);

$sql = "select severity from todos where id = '".$_GET['id']."'";
$severity = dbq1($sql);

$sql = "select hours from todos where id = '".$_GET['id']."'";
$hours = dbq1($sql);

#echo "<form action='addtask.php?zoom_id=".$_GET['zoom_id']."' method='POST'>";
echo "<form action='edittask.php?id=".$_GET['id']."&zoom_id=".$_GET['zoom_id']."' method='POST'>";
echo "<input type='hidden' name='pid' value='0' />";

echo "Parent<select name='pid' />";
echo "<option value='0'>-top-</option>\n";
get_recu_select();
echo "</select>";
echo "<br/>";

echo "txt";
echo "<textarea name=txt>";
echo $txt;
echo "</textarea>";
echo "<br />\n";


#echo "txt<input type='text' name='txt' value='".$txt."' />";
#echo "<br/>";

echo "hours<input type='text' name='hours' value='".$hours."' />";
echo "<br/>";

echo "prio<select name='prio'>\n";
for($i=0; $i<=10; $i++)
{
	echo "<option ";
	if($i == $prio)	{echo "selected='selected' ";}
	echo "value='".$i."'>".$i."</option>\n";
}
echo "</select><br/>\n";

echo "severity<select name='severity'>\n";
for($i=0; $i<=10; $i++)
{
	echo "<option ";
	if($i == $severity)	{echo "selected='selected' ";}
	echo "value='".$i."'>".$i."</option>\n";
}
echo "</select><br/>\n";

echo "<input type='submit' name='submit' value='submit' />";
echo "</form>";

#echo "<table border='1' style='border-collapse:collapse;'>";
#get_recu();
#echo "</table>";

require_once("bottom.php");
?>